package com.biz.hunter.wechat;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.biz.hunter.service.impl.SysConfigService;
import com.biz.qq.wechat.api.JSTicketAPI;
import com.biz.wechat.util.SignUtil;

@Controller
public class JSSDKMainController {
	private static final Logger logger = LoggerFactory
			.getLogger(JSSDKMainController.class);
	
	@Autowired
	private SysConfigService sysConfigService;
	
	@RequestMapping(value = "/util/getJSSignature.do", method = RequestMethod.GET)
	public @ResponseBody Map<String,String> checkSignature(
			@RequestParam(value = "url") String url) {
		Map<String, String> ret = new HashMap<String, String>();
		if (url != null) {
			String ticket = sysConfigService.getJsTicket();
			logger.debug("js api ticket is "+ticket);
			 ret  = SignUtil.getJSSignature(ticket, url);
			 logger.debug("return Signature is " + ret.get("signature"));
		} else {
			
		}
		return ret;
	}
}
